/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 *//*

package cz.worsik.android.test.rideshare.util.listener;

import android.view.View;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import cz.worsik.android.test.rideshare.R;
import cz.worsik.android.test.rideshare.MainActivity;
import cz.worsik.android.test.rideshare.model.list.ETableType;

public class SavePaymentListener implements View.OnClickListener
{
	MainActivity a;

	public SavePaymentListener(MainActivity a) {
		this.a = a;
	}
	
	public void onClick(View v) {

		View view = a.popup_window.getContentView();

		Spinner contact_paying = (Spinner) view.findViewById(R.id.popup_contact_paying);
		Spinner contact_receiving = (Spinner) view.findViewById(R.id.popup_contact_receiving);
		TextView amount = (TextView) view.findViewById(R.id.popup_amount);
		EditText note = (EditText) view.findViewById(R.id.popup_note);

		String paying_name = contact_paying.getSelectedItem().toString();
		String receiving_name = contact_receiving.getSelectedItem().toString();
		String amount_text = amount.getText().toString();

		String error = "\n";

		int amount_value = 0;
		if (!"".equals(amount_text)) {
			amount_value = Integer.parseInt(amount.getText().toString());
		}

		if (paying_name.equals(receiving_name))
		{
			error += a.getString(R.string.err_same_names)+"\n";
		}
		if (amount_value == 0)
		{
			error += a.getString(R.string.err_null_amount)+"\n";
		}

		if (!"\n".equals(error))
		{
			a.showToast(error, false);
			return;
		}

		String datum = a.getRok()+"-"+a.getCisloMesice()+"-"+a.getDen();

		a.getDb().open();
		Long retval = a.getDb().insertPayment(datum, receiving_name, paying_name, amount_value, note.getText().toString());
		a.getDb().close();

		if (retval > 0) {
			a.showToast(a.getString(R.string.msg_payment_saved,paying_name,receiving_name,amount_value)+a.getString(R.string.currency));
		}
		else {
			a.showToast(a.getString(R.string.msg_payment_not_saved));
		}

		a.generateBilanceTables();
		a.generateBilanceHistory(ETableType.PLATBY);
		a.popup_window.dismiss();
	}
}*/
